<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>resolve</title>
</head>
<body>
    <script>
        //Promise.resolve
        //resolve 是 Promise 函数对象身上的一个方法
        //快速创建 promise 实例对象, 会返回一个 promise 对象
            //如果实参不是一个 promise 对象,  返回的结果就是成功的 promise, 且成功的结果值为实参的值 
            //如果实参是一个 promise 对象, 该实参将决定返回的 promise


        //非 promise 参数的情况   
        // let p = Promise.resolve('ok');
        // let p2 = Promise.resolve(521);
        // let p3 = Promise.resolve(null);
        // let p4 = Promise.resolve(false);
        // let p5 = Promise.resolve(undefined);
        // let p6 = Promise.resolve();

        //promise 实参的情况
        // let p = Promise.resolve(new Promise((resolve, reject) => {
        //     // resolve('SUCCESS');
        //     reject('Fail');
        // }));

        // console.log(p);

        //测试
        // let p2 = Promise.resolve(Promise.resolve(Promise.resolve('ok')));
        // let p2 = Promise.reject(Promise.resolve(Promise.resolve('ok')));
        // let p2 = Promise.resolve(Promise.resolve(Promise.reject('Error')));
        let p2 = Promise.reject(Promise.resolve(Promise.reject('ok')));

        console.log(p2);
    </script>
</body>
</html>